<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    /*
    * 1. 字面量方式创建
    * 2. 使用构造函数
    * */

    /*
    * 构造函数
    * 写对象其实就是高度的总结 相同的特征为属性，相同的行为为方法
    * */

    function Phone(brand, size, weight, caizhi) {
        /*定义手机的属性*/
        this.brand = brand;
        this.size = size;
        this.weight = weight;
        this.caizhi = caizhi;

        /*定义手机的方法*/
        this.call = function () {
            console.log('this brand ' + this.brand, ' 可以打电话');
        }
        this.sendMessage = function (somebody) {
            console.log('this brand ' + this.brand, ' 可以发送短信，发送给：', somebody);
        }
    }

    var iphone12 = new Phone('苹果12', '18cm*5cm*2cm', '150g', '金属');

    console.log(iphone12.brand);
    iphone12.call();
    iphone12.sendMessage('王五');

</script>

</html>
